package jmu.cyxwcy.librarymanagement.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import jmu.cyxwcy.librarymanagement.pojo.BookDescription;
import jmu.cyxwcy.librarymanagement.pojo.College;
import jmu.cyxwcy.librarymanagement.mapper.CollegeMapper;
import jmu.cyxwcy.librarymanagement.service.ICollegeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 
 * @since 2024-06-26
 */
@Service
public class CollegeServiceImpl extends ServiceImpl<CollegeMapper, College> implements ICollegeService {


    @Override
    public List<College> findByCollegeNamPartial(String collegeNamePartial) {
        QueryWrapper<College> queryWrapper = new QueryWrapper<>();
        queryWrapper.likeRight("college_name", collegeNamePartial);
        return list(queryWrapper);
    }
    @Override
    public Integer findIdByCollegeName(String collegeName) {
        QueryWrapper<College> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("college_name", collegeName);
        College college = this.getOne(queryWrapper);
        return college != null ? college.getCollegeId() : null;
    }
}
